﻿package com.hxf.web.action.admin;

import java.io.IOException;
import java.util.List;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.hxf.common.PublicUtil;
import com.hxf.dto.MealBoxDto;
import com.hxf.dto.ReturnData;
import com.hxf.exception.ServiceException;
import com.hxf.web.action.WebActionBase;

/**
 * 包厢管理
 * @author tengyicheng
 *
 */
@Results({@Result(name = "success", location = "../common/success.jsp"), @Result(name = "error", location = "../common/error.jsp"), @Result(name = "msg", location = "../common/msg.jsp")})
public class BoxAction extends WebActionBase {
	private List<MealBoxDto> boxList;
	
	private String boxIds;
	private Integer status;
	private String name;
	
	/**
	 * 包厢列表
	 * @return
	 */
	public String boxList() {

		 try {
			 MealBoxDto mealBox = null;
			 if(PublicUtil.isNotNullAndEmpty(name)){
				 mealBox = new MealBoxDto();
				 mealBox.setName(name);
			 }
			ReturnData<MealBoxDto> result = super.serviceFacade.getMealBoxService().findByMealBoxPage(mealBox, targetPage, pageSize);
			boxList = result.getResultlist();
			this.setRecordCount(result.getRecordcount());
		 } catch (ServiceException e) {
			logger.debug(e.getMessage(), e);
		}
		return "box-list";
	}
	
	/**
	 * 审核通过 和 审核不通过
	 * @return
	 */
	public String audit() {
		try {
			int result = super.serviceFacade.getMealBoxService().updateMealBox(boxIds, status);
			println(result);
		} catch (ServiceException e) {
			logger.debug(e.getMessage(), e);
		} catch (IOException e) { 
			e.printStackTrace();
		}
		return null;
	}

	public List<MealBoxDto> getBoxList() {
		return boxList;
	}

	public void setBoxList(List<MealBoxDto> boxList) {
		this.boxList = boxList;
	}

	public String getBoxIds() {
		return boxIds;
	}

	public void setBoxIds(String boxIds) {
		this.boxIds = boxIds;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
}
